<template>
	<view>
		<view class="" style=" background-color: #fff;">
			<view class="wsitem">
				<view class="" style="width: 250rpx;">
					药店位置导航
				</view>
				<view class="" @click="daohang()" style="display: flex;">
					<text style="color: #007AFF;">
						{{weizhiname}}
					</text>
					<view style="width:40rpx;margin: auto 0; ">
						<image src="../../static/images/daohang.png" mode=""
							style="width:40rpx; height: 40rpx;margin: auto 0; padding-right: 30rpx;"></image>
					</view>
				</view>
			</view>
			<view class="wsitem">
				联系人姓名
				<input type="text" value="" placeholder="请填写姓名" class="myinput" v-model="name" />
			</view>
			<view class="wsitem">
				收货人电话
				<input type="number" value="" placeholder="请填写电话" class="myinput" maxlength="11" v-model="phone" />
			</view>
			<view class="wsitem">
				户名
				<input type="text" value="" placeholder="请填写户名" class="myinput" v-model="huming" />
			</view>
			<view class="wsitem">
				地址
				<pick-regions :default-regions="defaultRegions" @getRegions="handleGetRegions"
					style="text-align: right;">
					<text class="select-address" style="color: #007AFF;"
						:class="{ empty: !formData.full_address }">{{ formData.full_address ? formData.full_address : '请选择省市区县' }}</text>
				</pick-regions>
			</view>
			<view class="wsitem">
				详细地址
				<input type="text" value="" placeholder="请填写地址" class="myinput" v-model="address" />
			</view>



			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					发票信息(需要开专票的请提供发票信息和税号)
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload0" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<image :src="$util.img(imgList0)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
						@click="save0()">
					</image>
				</view>
			</view>
			<!-- <view class="wsitem" >
				发票信息
				<input type="text" value="" placeholder="需要开专票的请提供发票信息和税号" class="myinput"  style="width: 400rpx;" v-model="invoice"/>
			</view> -->


			<!-- <view style="display: flex; justify-content: space-between;">
				<view class="uni-title uni-common-pl">发票信息</view>
				<view class="" style="display: flex; justify-content: start;">
					<picker @change="bindPickerChange" :value="index" :range="array">
						<view class="uni-input">{{array[index]}}</view>
					</picker>
					<image src="../../static/images/select.png" mode=""
						style="width:15rpx; height: 30rpx;margin: auto 0; padding-right: 30rpx;"></image>
				</view>
			</view> -->


			<!-- 如果后台没有传来数据，就自己添加 -->

			<!-- 如果后台传来数据，就使用后台传来的数据-->
			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					营业执照
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save()">
						</image>
					</view>

				</view>
			</view>

			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					维保协议
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload1" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList1" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save1()">
						</image>
					</view>

				</view>
			</view>
			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					药品经营许可证
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload2" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList2" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save2()">
						</image>
					</view>

				</view>
			</view>
			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					食品经营许可证
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload3" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList3" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save3()">
						</image>
					</view>

				</view>
			</view>
			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					委托书
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload4" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList4" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save4()">
						</image>
					</view>

				</view>
			</view>
			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					身份证正面
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload5" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList5" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save5()">
						</image>
					</view>
				</view>
			</view>
			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					身份证反面
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload6" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList6" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save6()">
						</image>
					</view>


				</view>
			</view>
			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					年度报告
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload7" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view v-for="(item,index) in imgList7" :key="index">
						<image :src="$util.img(item)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save7()">
						</image>
					</view>

				</view>
			</view>





			<view class="upimg">
				<view class="" style="margin-bottom: 26rpx;">
					在五年之内有法人变更或地址变更请提供变更图片
				</view>
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view class="xianshiimg">
						<image :src="pingjiaSrc" @tap="upload8" style="width: 80rpx; height: 80rpx; margin: auto 0;">
					</view>
					<view>
						<image :src="$util.img(imgList8)" mode="" style="width: 200rpx; height: 200rpx; margin: 10rpx;"
							@click="save8()">
						</image>
					</view>

				</view>
			</view>


		</view>
		<view class="mysubmit" @click="tijiao()" style="margin-top: 34rpx;">
			提交审核
		</view>
	</view>
</template>

<script>
	import http from 'common/js/http.js';
	export default {
		data() {
			return {
				myNum: '',
				imgList8: [],
				name: '',
				phone: '',
				huming: '',
				address: '',
				weizhi: '',
				long: '',
				lat: '',
				weizhiname: '',
				imgList0: [],
				imgList: [],
				imgList1: [],
				imgList2: [],
				imgList3: [],
				imgList4: [],
				imgList5: [],
				imgList6: [],
				imgList7: [],
				invoice: '',
				title: 'picker',
				array: ['普票', '专票'],
				index: '',
				myinfo: '',
				imgArr: "",
				// pingjiaSrc: this.adminIp + "content/image/pingjia.png",
				pingjiaSrc: "../../static/add.png",
				defaultRegions: [],
				formData: {
					province: '',
					city: '',
					district: '',
					address: '',
					full_address: '',
					daohangdizhi: '',
				},
			}
		},
		mixins: [http],
		mounted() {
			console.log('11')
		},
		onLoad(e) {
			console.log('接受的值是', e)
			// 如果没有接收到参数就请求接口
			if (!e.address) {
				this.myNum = 0
				console.log('我没有接收到参数')
				this.getinfo();
			} else {
				//更改地址后获取到的e.address 再请求接口赋值给地址
				this.myNum = 1 //区别是否更改导航地址
				console.log('我接收到参数是', e)
				this.daohangdizhi = e
				console.log('自己获取的位置weizhiname是', e.address)
				this.getinfo(); //请求接口赋值地址
			}

			//获取用户是否完善过信息

		},
		methods: {
			// 获取选择的地区
			handleGetRegions(regions) {
				this.formData.full_address = '';
				this.formData.full_address += regions[0] != undefined ? regions[0].label : '';
				this.formData.full_address += regions[1] != undefined ? regions[1].label : '';
				this.formData.full_address += regions[2] != undefined ? regions[2].label : '';
				this.addressValue = '';
				this.addressValue += regions[0] != undefined ? regions[0].value : '';
				this.addressValue += regions[1] != undefined ? regions[1].value : '';
				this.addressValue += regions[2] != undefined ? regions[2].value : '';
				console.log('this.formData.full_address===========', this.formData.full_address)
			},

			getinfo() {
				console.log('我要获取了')
				this.sendRequest({
					url: 'System.Member.updaMemberstr',
					data: {},
					success: res => {
						console.log('获取用户是否完善过信息====', res)
						// res.code == 0没有数据
						// res.code == 1有数据
						if (res.code == 0) {
							if (this.myNum == 0) {
								this.weizhiname = res.data[6] //导航地址
							} else if (this.myNum == 1) {
								this.weizhi = this.daohangdizhi.address.split(',')
								this.lat = this.weizhi[0]
								this.long = this.weizhi[1]
								this.weizhiname = this.weizhi[2]

							}
							console.log('后台没有查到数据')

						} else {
							console.log('myNum===========', this.myNum)
							//0表示从后台获取的数据
							//1表示自己更改过导航地址
							// 否则有数据,就赋值
							this.name = res.data[0]
							this.phone = res.data[1]
							this.huming = res.data[2]
							this.address = res.data[3]

							if (this.myNum == 0) {
								this.weizhiname = res.data[6] //导航地址
							} else if (this.myNum == 1) {
								this.weizhi = this.daohangdizhi.address.split(',')
								this.lat = this.weizhi[0]
								this.long = this.weizhi[1]
								this.weizhiname = this.weizhi[2]
							}


							this.lat = res.data[4]
							this.long = res.data[5]
							this.imgList = res.data[8].zhizhao
							this.imgList1 = res.data[7].juebao
							this.imgList2 = res.data[9].xukezheng
							this.imgList3 = res.data[10].gsp
							this.imgList4 = res.data[11].weituoshu
							this.imgList5 = res.data[12].shenfenzheng
							this.imgList6 = res.data[12].shenfenzheng2
							this.imgList7 = res.data[13].ndbaogao
							this.imgList8 = res.data[16]
							this.imgList0 = res.data[14]
							this.formData.full_address = res.data[15]

							if (res.data[14] == '普票') {
								this.index = 0
							} else if (res.data[14] == '专票') {
								this.index = 1
							}

						}
					}
				});
			},
			tijiao() {
				this.sendRequest({
					url: 'System.Member.updaMember',
					data: {
						name: this.name,
						phone: this.phone,
						huming: this.huming,
						address: this.address,
						lat: this.lat,
						long: this.long,
						invoice: this.imgList0,
						invite: this.weizhiname,
						zhizhao: this.imgList,
						juebao: this.imgList1,
						xukezheng: this.imgList2,
						gsp: this.imgList3,
						weituoshu: this.imgList4,
						shenfenzheng: this.imgList5,
						shenfenzheng2: this.imgList6,
						ndbaogao: this.imgList7,
						biangeng: this.imgList8,
						city: this.formData.full_address,
					},
					success: res => {
						console.log('收到', res)
						if (res.code == 1) {
							console.log('res====', res)
							uni.showModal({
								// title: res.message + ',正在审核中',
								title: res.message,
								confirmText: '确认',
								cancelText: '取消',
								success: function(res) {
									// 退出登录
									uni.removeStorage({
										key: 'token',
										success: res => {
											uni.navigateTo({
												url: '/pages/login/login/login'
											})
										}
									});

									// uni.switchTab({
									// 	url: '/pages/member/index/index'
									// })

								}
							})
						}
						if (res.code == -1) {
							uni.showToast({
								title: res.message,
								icon: 'none',
								duration: 3000
							})
						}
					}
				});


				// if(this.name)

			},
			save() {
				console.log('预览');
				var paths = [];
				paths.push(this.$util.img(this.imgList0));
				uni.previewImage({
					urls: paths,
				});
			},
			save() {
				console.log('预览');
				var paths = [];
				paths.push(this.$util.img(this.imgList));
				uni.previewImage({
					urls: paths,
				});
			},
			save1() {
				var paths = [];
				paths.push(this.$util.img(this.imgList1));
				uni.previewImage({
					urls: paths,
				});
			},
			save2() {
				var paths = [];
				paths.push(this.$util.img(this.imgList2));
				uni.previewImage({
					urls: paths,
				});
			},
			save3() {
				var paths = [];
				paths.push(this.$util.img(this.imgList3));
				uni.previewImage({
					urls: paths,
				});
			},
			save4() {
				var paths = [];
				paths.push(this.$util.img(this.imgList4));
				uni.previewImage({
					urls: paths,
				});
			},
			save5() {
				var paths = [];
				paths.push(this.$util.img(this.imgList5));
				uni.previewImage({
					urls: paths,
				});
			},
			save6() {
				var paths = [];
				paths.push(this.$util.img(this.imgList6));
				uni.previewImage({
					urls: paths,
				});
			},
			save7() {
				var paths = [];
				paths.push(this.$util.img(this.imgList7));
				uni.previewImage({
					urls: paths,
				});
			},

			save8() {
				var paths = [];
				paths.push(this.$util.img(this.imgList8));
				uni.previewImage({
					urls: paths,
				});
			},
			upload0: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/zhuanpiao'
				}, res => {
					console.log('res==============', res)
					this.imgList0 = res
				});
			},
			upload: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/zhizhao'
				}, res => {
					console.log('res==============', res)
					this.imgList = res
				});
			},
			upload1: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/juebao'
				}, res => {
					console.log('res==============', res)
					this.imgList1 = res
				});
			},
			upload2: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/xukezheng'
				}, res => {
					console.log('res==============', res)
					this.imgList2 = res
				});
			},
			upload3: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/gsp'
				}, res => {
					console.log('res==============', res)
					this.imgList3 = res
				});
			},
			upload4: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/weituoshu'
				}, res => {
					console.log('res==============', res)
					this.imgList4 = res
				});
			},
			upload5: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/shenfenzheng'
				}, res => {
					console.log('res==============', res)
					this.imgList5 = res
				});
			},
			upload6: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/fanmian'
				}, res => {
					console.log('res==============', res)
					this.imgList6 = res
				});
			},
			upload7: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/ndbaogao'
				}, res => {
					console.log('res==============', res)
					this.imgList7 = res
				});
			},

			upload8: function() {
				this.$util.upload(1, {
					file_path: 'ziliao/ndbaogao'
				}, res => {
					console.log('res==============', res)
					this.imgList8 = res
				});
			},
			//查看图片

			daohang() {
				uni.navigateTo({
					url: '/pages/map/map'
				})
			},

		}
	}
</script>

<style>
	page {
		background-color: #fff;
		padding-bottom: 30rpx;
	}

	.mysubmit {

		text-align: center;
		display: flex;
		justify-content: center;
		align-items: center;
		width: 220rpx;
		height: 65rpx;
		margin: 0 auto;
		background: #F24450;
		border-radius: 33rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		font-family: Source Han Sans CN;
	}

	.xianshiimg {
		width: 200rpx;
		height: 200rpx;
		border: 1rpx solid #CCCCCC;
		display: flex;
		justify-content: center;
	}

	.showimg_box {
		display: flex;
		align-items: center;
		margin-top: 20upx;

	}

	.show_img {
		width: 140upx;
		height: 140upx;
		border: 2upx dashed #eee;
		margin: 20upx 0;

		image {
			width: 100%;
			height: 100%;
			border: 2upx dashed #eee;
		}
	}

	.images {
		width: 140upx;
		height: 140upx;
		z-index: 999;
	}

	.imgarr {
		position: relative;
		margin: 0 10upx;
	}

	.icon-cuo {
		font-family: 'iconfont';
		position: absolute;
		right: 0;
		top: 0;
		background-color: #fff;
		z-index: 10009;
		width: 30rpx;
		height: 30rpx;
		border-radius: 50%;
	}




	.myinput {
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #333333;
		font-size: 24rpx;
		text-align: right;

	}

	.upimg {
		padding-top: 38rpx;
		height: auto;
		padding-left: 30rpx;
		padding-right: 30rpx;
		padding-bottom: 29rpx;
		border: 1rpx solid #DCDCDC;

	}

	.wsitem {
		height: 100rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border: 1rpx solid #DCDCDC;

	}

	.wsitem1 {
		height: 100rpx;
		border: 1rpx solid #DCDCDC;
	}
</style>
